package com.eos.control.action.customer;

import com.eos.business.service.SysProductBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.ProductModel;
import com.eos.orm.mybatis.model.SysUser;

public class UpdateCategoryAction extends AbstractBaseAction {
	private static final long serialVersionUID = 169769270030882375L;
	private Integer modelId;
	private String modelName;
	private Integer brandId;
	private Integer sysProductId;
	private String modelDesc;
	
	public void setModelId(Integer modelId) {
		this.modelId = modelId;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public void setBrandId(Integer brandId) {
		this.brandId = brandId;
	}

	public void setSysProductId(Integer sysProductId) {
		this.sysProductId = sysProductId;
	}

	public void setModelDesc(String modelDesc) {
		this.modelDesc = modelDesc;
	}

	@Override
	public String execute() {
		try {
			if (null == modelId || modelId.longValue() <= 0) {
				statusCode = "300";
				message = "参数错误, 保存信息失败!";
			} else {
				SysProductBusinessService spbs = new SysProductBusinessService();
				ProductModel pm = new ProductModel();
				pm.setBrandId(brandId);
				pm.setModelName(modelName);
				pm.setStatus(ConstantTool.STATUS_OK);
				pm.setDealFlag(ConstantTool.DEAL_FALG_OK);
				 
				String strTime = ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss");
				SysUser user = (SysUser) getSession().getAttribute("SysUser");
				String userId = user.getId()+"";
				pm.setModifyTime(strTime);
				pm.setUpdateUserId(userId);
				pm.setProductId(sysProductId); 
				pm.setId(modelId);
				pm.setModelDesc(modelDesc);
				String exeStatus = spbs.updateProductModelPKSelective(pm);
				if("SUCCESS".equals(exeStatus)){
					statusCode = "200";
					message = "修改型号信息成功!";
				}else{
					statusCode = "300";
					message = "系统繁忙, 修改型号信息失败!";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 修改型号信息失败!";
		}
		return SUCCESS;
	}

}
